//
//  DetailHeardView.m
//  Travel assistant
//
//  Created by 杨帆 on 16/3/14.
//  Copyright © 2016年 旅游助手. All rights reserved.
//

#import "DetailHeardView.h"
#import "DetailBannerModel.h"
@interface DetailHeardView ()

@property(nonatomic,strong)UIImageView *trackpoints_thumbnail_image;
@property(nonatomic,strong)UILabel *nameL;
@property(nonatomic,strong)UILabel *horizontalLine;
@property(nonatomic,strong)UILabel *first_dayL;
@property(nonatomic,strong)UILabel *day_count;
@property(nonatomic,strong)UILabel *verticallineOne;
@property(nonatomic,strong)UILabel *mileageTitle;
@property(nonatomic,strong)UILabel *mileageL;
@property(nonatomic,strong)UILabel *verticallineTwo;
@property(nonatomic,strong)UILabel *recommendationsTitle;
@property(nonatomic,strong)UILabel *recommendationsL;
@property(nonatomic,strong)UILabel *horizontalLineTwo;


@end

@implementation DetailHeardView

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        
        [self addViews];
        
    }
    
    return self;

}

-(void)addViews{
    
    
    
    self.trackpoints_thumbnail_image = [[UIImageView alloc]initWithFrame:(CGRectMake(0, 0, KScreenWidth, 0.35*KScreenHeight))];
    self.trackpoints_thumbnail_image.layer.cornerRadius = 10;
    self.trackpoints_thumbnail_image.layer.masksToBounds = YES;
    [self addSubview:self.trackpoints_thumbnail_image];
    
    self.nameL = [[UILabel alloc]initWithFrame:(CGRectMake(0, 0.35*KScreenHeight, KScreenWidth, 0.12*KScreenHeight))];
    self.nameL.numberOfLines = 0;
    self.nameL.textAlignment = NSTextAlignmentCenter;
    self.nameL.font= [UIFont fontWithName:@"Helvetica-Bold" size:24];
    [self addSubview:self.nameL];
    
    self.horizontalLine = [[UILabel alloc]initWithFrame:(CGRectMake(0, 0.47*KScreenHeight, KScreenWidth, 0.003*KScreenHeight))];
    self.horizontalLine.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.95 alpha:1];
    [self addSubview:self.horizontalLine];
    
    self.first_dayL = [[UILabel alloc]initWithFrame:(CGRectMake(0, 0.473*KScreenHeight, 0.328*KScreenWidth, 0.054*KScreenHeight))];
    self.first_dayL.numberOfLines = 0;
    self.first_dayL.textAlignment = NSTextAlignmentCenter;
    self.first_dayL.font= [UIFont fontWithName:@"Helvetica-Bold" size:14];
    [self addSubview:self.first_dayL];
    
    
    self.day_count = [[UILabel alloc]initWithFrame:(CGRectMake(0, 0.527*KScreenHeight, 0.328*KScreenWidth, 0.054*KScreenHeight))];
    self.day_count.numberOfLines = 0;
    self.day_count.textAlignment = NSTextAlignmentCenter;
    self.day_count.font= [UIFont fontWithName:@"Helvetica-Bold" size:12];
    [self addSubview:self.day_count];
    
    self.verticallineOne = [[UILabel alloc]initWithFrame:(CGRectMake(0.328*KScreenWidth, 0.491*KScreenHeight, 0.003*KScreenWidth, 0.068*KScreenHeight))];
    self.verticallineOne.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.95 alpha:1];
    
    [self addSubview:self.verticallineOne];
    
    
    self.mileageTitle = [[UILabel alloc]initWithFrame:(CGRectMake(0.331*KScreenWidth, 0.473*KScreenHeight, 0.328*KScreenWidth, 0.054*KScreenHeight))];
    self.mileageTitle.numberOfLines = 0;
    self.mileageTitle.textAlignment = NSTextAlignmentCenter;
    self.mileageTitle.font= [UIFont fontWithName:@"Helvetica-Bold" size:14];
    self.mileageTitle.text = @"里程";
    [self addSubview:self.mileageTitle];
    
    self.mileageL = [[UILabel alloc]initWithFrame:(CGRectMake(0.331*KScreenWidth, 0.527*KScreenHeight, 0.328*KScreenWidth, 0.054*KScreenHeight))];
    self.mileageL.numberOfLines = 0;
    self.mileageL.textAlignment = NSTextAlignmentCenter;
    self.mileageL.font= [UIFont fontWithName:@"Helvetica-Bold" size:12];
    [self addSubview:self.mileageL];
    
    self.verticallineTwo = [[UILabel alloc]initWithFrame:(CGRectMake(0.659*KScreenWidth, 0.491*KScreenHeight, 0.003*KScreenWidth, 0.068*KScreenHeight))];
    self.verticallineTwo.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.95 alpha:1];
    
    [self addSubview:self.verticallineTwo];
    
    
    self.recommendationsTitle = [[UILabel alloc]initWithFrame:(CGRectMake(0.662*KScreenWidth, 0.473*KScreenHeight, 0.328*KScreenWidth, 0.054*KScreenHeight))];
    self.recommendationsTitle.numberOfLines = 0;
    self.recommendationsTitle.textAlignment = NSTextAlignmentCenter;
    self.recommendationsTitle.font= [UIFont fontWithName:@"Helvetica-Bold" size:14];
    self.recommendationsTitle.text = @"喜欢";
    [self addSubview:self.recommendationsTitle];
    
    self.recommendationsL = [[UILabel alloc]initWithFrame:(CGRectMake(0.662*KScreenWidth, 0.527*KScreenHeight, 0.328*KScreenWidth, 0.054*KScreenHeight))];
    self.recommendationsL.numberOfLines = 0;
    self.recommendationsL.textAlignment = NSTextAlignmentCenter;
    self.recommendationsL.font= [UIFont fontWithName:@"Helvetica-Bold" size:12];
    [self addSubview:self.recommendationsL];
    
    
    self.horizontalLine = [[UILabel alloc]initWithFrame:(CGRectMake(0, 0.581*KScreenHeight, KScreenWidth, 0.003*KScreenHeight))];
    self.horizontalLine.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.95 alpha:1];
    [self addSubview:self.horizontalLine];

}

- (void)setData:(DetailBannerModel *)model{
    [self.trackpoints_thumbnail_image sd_setImageWithURL:[NSURL URLWithString:model.trackpoints_thumbnail_image] placeholderImage:nil];
    self.day_count.text = [model.day_count stringValue];
    self.first_dayL.text = model.first_day;
    
    NSString *string =[model.mileage stringValue];
    NSArray *array = [string componentsSeparatedByString:@"."];
    self.mileageL.text = array[0];
    self.nameL.text = model.name;
    self.recommendationsL.text = [model.recommendations stringValue];
    
}





@end
